package personne;



import film.Film;
import film.Participer;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.PrimaryKeyJoinColumns;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import jdk.nashorn.internal.objects.annotations.Setter;
import recompenses.RecompenserPersonne;


@Entity
@Table(name = "personne")
public class Personne extends Persistant{
	/**
	 * 
	 */
	private static final long serialVersionUID = -7094180305638316258L;
	

	@Column(name = "lien_photo")
	private String lien_photo = "lien";
	
	@Column(name = "date_naissance")
	@Temporal(TemporalType.DATE)
	private Date date_naissance = Calendar.getInstance().getTime();
	
	@Column(name = "nbr_cliques")
	private int nbrCliques = 0;
	
	@Column(name = "valide")
	private int valide = 1;
	
	@Column(name = "date_creation")
	@Temporal(TemporalType.DATE)
	private Date date_creation = Calendar.getInstance().getTime();
	
	
	@OneToMany(mappedBy = "personne", cascade = { CascadeType.REMOVE }) 
    private Set<RecompenserPersonne> recompense = new HashSet<RecompenserPersonne>();
	
	@OneToMany(mappedBy = "personne", cascade = { CascadeType.REMOVE }) 
    private Set<Participer> film = new HashSet<Participer>();
	
	
	
	@Transient
	public ArrayList<Film> listFilm;
	
	public Personne ()
	{}
	
	public Personne(int code , String nom , String prenom ,Date dateNaissance , String lienPhoto , int nbc)
	{
		this.setCode_per(code);
		this.setLien_photo(lienPhoto);
		this.setPrenom(prenom);
		this.setNom(nom);
		this.setDate_naissance(dateNaissance);
		this.setNbrCliques(nbc);
		
	}

	
	public Personne(int code , String nom , String prenom ,Date dateNaissance , String lienPhoto , int nbc , Date date)
	{
		this.setCode_per(code);
		this.setLien_photo(lienPhoto);
		this.setPrenom(prenom);
		this.setNom(nom);
		this.setDate_naissance(dateNaissance);
		this.setNbrCliques(nbc);
		this.setDate_creation(date);
		this.setValide(0);
		
	}
	

	public Date getDate_naissance() {
		return date_naissance;
	}

	public void setDate_naissance(Date date_naissance) {
		this.date_naissance = date_naissance;
	}


	public int getNbrCliques() {
		return nbrCliques;
	}

	public void setNbrCliques(int nbrCliques) {
		this.nbrCliques = nbrCliques;
	}

	



	public Set<RecompenserPersonne> getRecompense() {
		return recompense;
	}

	public void setRecompense(Set<RecompenserPersonne> recompense) {
		this.recompense = recompense;
	}

	public Set<Participer> getFilm() {
		return film;
	}

	public void setFilm(Set<Participer> film) {
		this.film = film;
	}

	public String getLien_photo() {
		return lien_photo;
	}

	public void setLien_photo(String lien_photo) {
		this.lien_photo = lien_photo;
	}

	public int getValide() {
		return valide;
	}

	public void setValide(int valide) {
		this.valide = valide;
	}

	public Date getDate_creation() {
		return date_creation;
	}

	public void setDate_creation(Date date_creation) {
		this.date_creation = date_creation;
	}



	
	
	
	
}

